package com.xbts.system.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xbts.system.mapper.SeiMaterialTemplateMapper;
import com.xbts.system.domain.SeiMaterialTemplate;
import com.xbts.system.service.ISeiMaterialTemplateService;
import com.xbts.common.utils.DateUtils;
import com.xbts.common.utils.SecurityUtils;

/**
 * 模板素材关联Service业务层处理
 * 
 * @author xbts
 * @date 2023-09-08
 */
@Service
public class SeiMaterialTemplateServiceImpl  extends ServiceImpl<SeiMaterialTemplateMapper, SeiMaterialTemplate> implements ISeiMaterialTemplateService {

    /**
     * 查询模板素材关联列表
     *
     * @param seiMaterialTemplate 模板素材关联
     * @return 模板素材关联
     */
    @Override
    public List<SeiMaterialTemplate> selectSeiMaterialTemplateList(SeiMaterialTemplate seiMaterialTemplate) {
        QueryWrapper<SeiMaterialTemplate> queryWrapper = seiMaterialTemplate.queryWrapper();
        return list(queryWrapper);
    }

    /**
     * 查询模板素材关联
     *
     * @param id 模板素材关联主键
     * @return 模板素材关联
     */
    @Override
    public SeiMaterialTemplate selectSeiMaterialTemplateById(String id) {
        return getById(id);
    }

    /**
     * 新增模板素材关联
     *
     * @param seiMaterialTemplate 模板素材关联
     * @return 结果
     */
    @Override
    public boolean insertSeiMaterialTemplate(SeiMaterialTemplate seiMaterialTemplate) {
        seiMaterialTemplate.setCreateBy(SecurityUtils.getUserId().toString());
        return save(seiMaterialTemplate);
    }

    /**
     * 修改模板素材关联
     *
     * @param seiMaterialTemplate 模板素材关联
     * @return 结果
     */
    @Override
    public boolean updateSeiMaterialTemplate(SeiMaterialTemplate seiMaterialTemplate) {
        seiMaterialTemplate.setUpdateBy(SecurityUtils.getUserId().toString());
        seiMaterialTemplate.setUpdateTime(DateUtils.getNowDate());
        return updateById(seiMaterialTemplate);
    }

    /**
     * 批量删除模板素材关联
     *
     * @param ids 需要删除的模板素材关联主键
     * @return 结果
     */
    @Override
    public boolean deleteSeiMaterialTemplateByIds(List<String> ids) {
        return removeBatchByIds(ids);
    }

    /**
     * 删除模板素材关联信息
     *
     * @param id 模板素材关联主键
     * @return 结果
     */
    @Transactional
    @Override
    public boolean deleteSeiMaterialTemplateById(String id) {
      return removeById(id);
    }

}
